﻿#region using...
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
#endregion

namespace Infusion.Silverlight.Controls.Menu
{
    #region : MenuSeparator :
    #region TemplateParts...
    [TemplatePart(Name = MenuSeparator.MenuSeparatorLayoutRoot, Type = typeof(Grid))]
    [TemplatePart(Name = MenuSeparator.LineSeparator, Type = typeof(Line))]
    [TemplatePart(Name = MenuSeparator.LineSeparatorClip, Type = typeof(RectangleGeometry))]
    #endregion
    public class MenuSeparator : Control, IMenuItem
    {
        #region TemplatePart Names...
        public const string MenuSeparatorLayoutRoot = "MenuSeparatorLayoutRoot";
        public const string LineSeparator = "LineSeparator";
        public const string LineSeparatorClip = "LineSeparatorClip";
        #endregion

        #region TemplatePart Variables...
        internal Grid menuSeparatorLayoutRoot;
        internal Line lineSeparator;
        internal RectangleGeometry lineSeparatorClip;
        #endregion

        #region Class Variables...
        private Menu parentMenu = null;
        private bool templateApplied = false;
        private double yOffset = 0;
        #endregion

        #region Constructor(s)...
        #region MenuSeparator
        public MenuSeparator() : base()
        {
            DefaultStyleKey = typeof(MenuSeparator);
        }
        #endregion
        #endregion

        #region Methods...
        #region OnApplyTemplate
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (!templateApplied)
            {
                menuSeparatorLayoutRoot = (Grid)GetTemplateChild(MenuSeparatorLayoutRoot);
                lineSeparator = (Line)GetTemplateChild(LineSeparator);
                lineSeparatorClip = (RectangleGeometry)GetTemplateChild(LineSeparatorClip);

                templateApplied = true;
            }
        }
        #endregion
        #endregion

        #region Properties...
        #region RealWidth
        public double RealWidth
        {
            get { return ActualWidth; }
        }
        #endregion

        #region RealHeight
        public double RealHeight
        {
            get { return ActualHeight; }
        }
        #endregion

        #region ParentMenu
        public Menu ParentMenu
        {
            get { return parentMenu; }
            set { parentMenu = value; }
        }
        #endregion

        #region YOffset
        public double YOffset
        {
            get { return yOffset; }
            set { yOffset = value; }
        }
        #endregion
        #endregion
    }
    #endregion
}